//
//  CAReturnGoodsApi.m
//  LNH
//
//  Created by twentylx on 2018/2/24.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAReturnGoodsApi.h"
#import "AFURLRequestSerialization.h"

@implementation CAReturnGoodsApi {
    NSString *_orderId;
    NSString *_orderGoodsId;
    NSString *_goodsStatus;
    NSString *_reason;
    NSString *_content;
    UIImage *_image1;
    UIImage *_image2;
    UIImage *_image3;
}

- (instancetype) initWithOrderId:(NSString *) orderId orderGoodsId:(NSString *)orderGoodsId GoodsStatus:(NSString *)goodsStatus Reason:(NSString *)reason Content:(NSString *)content Image1:(UIImage *)image1 Image2:(UIImage *)image2 Image3:(UIImage *)image3{
    self = [super init];
    if (self) {
        _orderId = orderId;
        _orderGoodsId = orderGoodsId;
        _goodsStatus = goodsStatus;
        _reason = reason;
        _content = content;
        _image1 = image1;
        _image2 = image2;
        _image3 = image3;
    }
    return self;
}

-(YTKRequestMethod)requestMethod{
    return YTKRequestMethodPOST;
}

-(AFConstructingBlock)constructingBodyBlock{
    return ^(id<AFMultipartFormData> formData) {
        if (_image1) {
            NSData *data = UIImageJPEGRepresentation(_image1, 0.5);
            NSString *name = @"image.jpg";
            NSString *formKey = [NSString stringWithFormat:@"img_one"];
            NSString *type = @"image/jpeg";
            [formData appendPartWithFileData:data
                                        name:formKey
                                    fileName:name mimeType:type];
        }
        if (_image2) {
            NSData *data = UIImageJPEGRepresentation(_image1, 0.5);
            NSString *name = @"image2.jpg";
            NSString *formKey = [NSString stringWithFormat:@"img_two"];
            NSString *type = @"image/jpeg";
            [formData appendPartWithFileData:data
                                        name:formKey
                                    fileName:name mimeType:type];
        }
        if (_image3) {
            NSData *data = UIImageJPEGRepresentation(_image3, 0.5);
            NSString *name = @"image3.jpg";
            NSString *formKey = [NSString stringWithFormat:@"img_three"];
            NSString *type = @"image/jpeg";
            [formData appendPartWithFileData:data
                                        name:formKey
                                    fileName:name mimeType:type];
        }
    };
}

-(id)requestArgument{
    return @{
             @"token":GVUD.token,
             @"order_id":_orderId,
             @"order_goods_id":_orderGoodsId,
             @"goods_status":_goodsStatus,
             @"reason":_reason,
             @"content":_content,
             };
}

-(NSString *)requestUrl{
    NSLog(@"%@", [NSString stringWithFormat:@"%@returnOrderApp",BASE_SERVICE_DOMAIN]);
    return [NSString stringWithFormat:@"%@returnOrderApp",BASE_SERVICE_DOMAIN];
    
    
}

@end
